<template>
	<div>
		<el-form ref="PatientMess">
			<el-form-item>
				<el-col :span="5">
					<el-button type="primary" @click="BackToHome()">返回病例首页</el-button>
				</el-col>
				<el-col :span="10">
					<el-button type="danger" @click="ToEmpty()">清屏</el-button>
				</el-col>
			</el-form-item>
			<el-form-item prop="id" label="ID" >
				<el-input v-model="PatientMess.id" readonly :disabled="true"></el-input>
			</el-form-item>
			<el-form-item prop="casenumber" label="病例号">
				<el-input v-model="PatientMess.casenumber" readonly :disabled="true"></el-input>
			</el-form-item>
			<el-form-item prop="registid" label="挂号ID">
				<el-input v-model="PatientMess.registid" readonly :disabled="true"></el-input>
			</el-form-item>
			<el-form-item prop="readme" label="主诉">
				<el-input v-model="PatientMess.readme" readonly :disabled="true"></el-input>
			</el-form-item>
			<el-form-item prop="present" label="现病治疗情况">
				<el-input v-model="PatientMess.present" type="textarea" :disabled="true" ></el-input>
			</el-form-item>
			<el-form-item prop="history" label="既往史">
				<el-input v-model="PatientMess.history" readonly :disabled="true"></el-input>
			</el-form-item>
			<el-form-item prop="allergy" label="过敏史">
				<el-input v-model="PatientMess.allergy" readonly :disabled="true"></el-input>
			</el-form-item>
			<el-form-item prop="physique" label="体格检查">
				<el-input v-model="PatientMess.physique" readonly :disabled="true"></el-input>
			</el-form-item>
			<el-form-item prop="proposal" label="检查建议">
				<el-input v-model="PatientMess.proposal"></el-input>
			</el-form-item>
			<el-form-item prop="careful" label="注意事项">
				<el-input v-model="PatientMess.careful"></el-input>
			</el-form-item>
			<el-form-item prop="checkresult" label="检查结果">
				<el-input v-model="PatientMess.checkresult"></el-input>
			</el-form-item>
			<el-form-item prop="diagnosis" label="诊断意见">
				<el-input v-model="PatientMess.diagnosis"></el-input>
			</el-form-item>
			<el-form-item prop="handling" label="处理意见">
				<el-input v-model="PatientMess.handling"></el-input>
			</el-form-item>
			<!-- <el-form-item prop="casestate" label="病例状态">
				<el-input v-model="PatientMess.casestate"></el-input>
			</el-form-item> -->
			<el-form-item>
				<el-col :span="1">
					<el-button type="primary" @click="UpdateToSub()">提交</el-button>
				</el-col>
				<el-col :span="5">
					<el-button type="primary" @click="UpdateToStorage()">暂存</el-button>
				</el-col>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		name: "PantientPage",
		data() {
			return {
				PatientMess: {},
				// values:{
				// 	proposal:'',
				// 	careful:'',
				// 	checkresult:'',
				// 	diagnosis:'',
				// 	handling:'',
				// }
			}
		},
		mounted() {
			this.PatientMess.casenumber = this.$route.query.casenumber;
			// console.log('this.$route.query.id='+this.$route.query.casenumber);
			let url = '/MedicalRecord/selectByCaseNumber'
			let param = this.$qs.stringify(this.PatientMess)
			// console.log('--param='+param);
			this.$axios.post(url, param)
				.then((resp) => {
					this.PatientMess = resp.data
					console.log('this.ruleForm=', this.PatientMess)
				})
				.catch((err) => {
					console.log('error=', err)
				})
		},
		methods: {
			BackToHome() {
				this.$router.push('/HomePage')
			},
			UpdateToSub() {
				let url = '/MedicalRecord/UpdateToSub';
				// this.user.act='update';
				let param = this.$qs.stringify(this.PatientMess)
				this.$axios.post(url, param)
					.then((resp) => {
						let i = resp.data;
						if (i > 0) {
							alert('提交成功!')
							this.$router.push('/HomePage')
						} else {
							alert('提交失败!')
						}
					})
					.catch((err) => {
						console.log('error=', err)
					})
			},
			UpdateToStorage() {
				let url = '/MedicalRecord/UpdateToStorage';
				let param = this.$qs.stringify(this.PatientMess)
				this.$axios.post(url, param)
					.then((resp) => {
						let i = resp.data;
						if (i > 0) {
							alert('暂存成功!')
							this.$router.push('/HomePage')
						} else {
							alert('暂存失败!')
						}
					})
					.catch((err) => {
						console.log('error=', err)
					})
			},
			ToEmpty(){
				this.PatientMess.proposal ='';
				this.PatientMess.careful='';
				this.PatientMess.checkresult='';
				this.PatientMess.diagnosis='';
				this.PatientMess.handling='';
				return this.$message.success("已清空!");
			}
		}
	}
</script>

<style>
</style>
